﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WSS.hameduconn.Business;
using WSS.hameduconn.Business.Dto;

namespace WSS.hameduconn.Controllers
{
    public class AdminController : Controller
    {
        //
        // GET: /Admin/
        public ActionResult Index(int UserId, string UserName)
        {
            List<RegistrationsDto> lstRegistrations = new List<RegistrationsDto>();
            lstRegistrations = RegistrantionBusines.GetRegistrationList();
            ViewBag.RegistrationList = lstRegistrations;
            ViewBag.UserId = UserId;    
            ViewBag.UserName = UserName;            
            return View();
        }

        public ActionResult CreateUser(int UserId, string UserName)
        {
            ViewBag.UserId = UserId;
            ViewBag.UserName = UserName;    
            return View();
        }

        public ActionResult Signout()
        {
            Session.RemoveAll();
            return Redirect("~/Home");
        }

        public ActionResult EditUser(int id, int UserId, string UserName)
        {
            ViewBag.UserId = UserId;
            ViewBag.UserName = UserName; 
            RegistrationsDto registration = RegistrantionBusines.GetRegistrationById(id);
            return View(registration);
        }

        public ActionResult UpdatedUser(RegistrationsDto registration, int UserId, string UserName)
        {
            RegistrantionBusines.Updated(registration);
            return RedirectToAction("Index", new { UserId = UserId, UserName = UserName });
        }

        public ActionResult DeletedUser(int id, int UserId, string UserName)
        {
            string s = ViewBag.UserName;
            RegistrationsDto registration = RegistrantionBusines.GetRegistrationById(id);
            RegistrantionBusines.Deleted(registration);
            return RedirectToAction("Index", new { UserId = UserId, UserName = UserName });
        }
	}
}